home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3182 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news1.cle.ab.com!usenet
  2. From: don.phillips@ab.com (Donald-Anthony C. Phillips)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Finding a prime number
  5. Date: Fri, 26 Jan 1996 22:05:27 GMT
  6. Organization: The Allen-Bradley Co., Inc
  7. Distribution: inet
  8. Message-ID: <4eb8lo$9rf@news1.cle.ab.com>
  9. References: <4e875s$nqk@reader2.ix.netcom.com>
  10. NNTP-Posting-Host: abpc386.cle.ab.com
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13.     It seems your algorithm may not be mathematically correct.  Your
  14. assumption( if i'm reading your code right) is that if a number is not
  15. divisible evenly by any of the numbers 0-9, then it must be prime.
  16. This is not correct. 
  17.     Take for instance the number 247.  It is not divisible by 0-9 but it
  18. is not a prime number( 13*19 = 247).  The definition of a prime number
  19. is a number divisible only by one and the number.
  20.     Most prime number algorithms will be iterative or recursive by nature.
  21. A number (n)  is prime if is not divisible by any number from 2 thru
  22. (n - 1) .....roughly.  There are also some much more theoretical
  23. models that can be used but the previous definition will do.
  24. Donald-Anthony C. Phillips
  25. Programmer/Analyst
  26.  Rockwell  Automation
  27.        ---------------------------------------
  28.         Allen-Bradley
  29. don.phillips@ab.com
  30.  
  31.